home *** CD-ROM | disk | FTP | other *** search
- «RHA«PT3»«MDNM»«LS1»«LM2»«RM78»«FL»
- ARTICLE #508046«LD »PAGE «PN»
- «LD_»
-
-
- »«LS2»«LM7»«FL»«SSMATH,fc»«SSPAR,IP5,0»«SSFPAR,IP0,0»«SSCAPTIONS,ls1,IP0,MDRV»«SSDECK,MDBO»«SSCOLQUOTE,RM37,MDRV»«SSBYLINE,MDBO»«SSHEAD,MDBO»«SSSUBH,IP0,MDBO»«SSLISTING,PT1,lm7,RM63,IP0,15,LS1»«SSHANG,IP0,2»«SSBIO,MDRV»«USLISTING»CLS: PRINT "CONREC example. Graph the equipotential lines"
- print "around two charg particles by contouring the function"
- print: print "V(x,y)=q1/r1 - q2/r2"
- print "letting x and y range from -4 to 4."
- OPTION BASE 0 'Lower bound of zero for all array indices
- pi=3.141592654#
- true=-1 : false=0
- ilength=319 : jlength=199 'Dimensions of the output contour plot axes (full screen in CGA mode)
- imin=0 :jmin=199 'Coordinates of the left bottom corner
- iub=30 : jub=30 : nc=8 'Number of grid intervals and contour levels
- DIM d(iub,jub),x(iub),y(jub) 'Data array
- DIM z(nc-1) 'Contour array
- REM
- REM Define the function and the coordinates
- a=1.5 : q1=1 : q2=-4 'Charge q1 is at -a; q2 is at +a
- FOR i=0 TO iub
- ix=4*(2*i-iub)/iub 'Range from -4 to 4
- FOR j=0 TO jub
- jy=4*(2*j-jub)/jub 'Range from -4 to 4
- r1=SQR((ix-a)^2+jy^2)
- r2=SQR((ix+a)^2+jy^2)
- d(i,j)=(q1/r1-q2/r2)
- NEXT j
- x(i)=i*ilength/iub+imin 'Scale x(i) to span plot area
- NEXT i
- FOR j=0 TO jub
- y(j)=jmin-j*jlength/jub 'Scale y(i) to span plot area
- NEXT j
- FOR i=0 TO nc-1 : z(i)=(i+1)/2 : NEXT i
- REM
- CLS: SCREEN 1,0 'CGA screen 320 x 200
- LINE(imin,jmin-jlength)-(imin+ilength,jmin),,b 'Use a box for axes
- GOSUB conrec
- IF NOT(prmerr) THEN PRINT : PRINT : PRINT msg$;
- WHILE LEN(INKEY$)=0 : WEND 'Any key to stop
- CLS : WINDOW CLOSE 1
- END